<template>
  <div class="contant">
    <div class="auth">
      <el-form
        ref="formInline"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <el-form-item label="用户ID">
          <el-input v-model="formInline.uid" placeholder="账号"></el-input>
        </el-form-item>
        <el-form-item label="岗位权限">
          <el-select v-model="formInline.role" placeholder="权限列表">
            <!-- <el-option label="数据标注作业岗" value="G040BZ000001"></el-option>
            <el-option label="标注项目管理岗" value="G040BZ000002"></el-option> -->
            <el-option label="数据标注作业岗" value="work"></el-option>
            <el-option label="标注项目管理岗" value="manage"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item class="block">
          <el-button type="primary" @click="onSubmit">提交</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<style lang="less" scoped>
.contant {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  .block {
    display: block;
    text-align: center;
  }
}
</style>
<script>
import {setAuth} from "@/api/all.js"
export default {
    data() {
      return {
        formInline: {
          uid: '',
          role: ''
        }
      }
    },
    methods: {
      async onSubmit() {
        if (!this.formInline.uid||!this.formInline.role) {
          this.$message({
            type: "warning",
            message: "请输入用户ID和岗位权限"
          });
        }else {
          let res =  await setAuth(this.formInline)
        if (res.code!="200") {
          this.$message({
            type: "warning",
            message: res.message
          });
        }else {
          this.$message({
            type: "success",
            message: "添加岗位成功"
          });
          this.resetForm()
        }
        }
      },
      resetForm() {
        this.formInline.uid='';
        this.formInline.role=''
      }
    }
  }
</script>
